package com.haiheng.library_base.utils

import android.app.Activity
import android.app.ActivityManager
import android.content.Context

/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2022/11/10 0010
 * @Version: 1.0
 */
object ServiceUtils {
    /**
     * 判断服务是否运行
     */
    fun isServiceRunning(activitty:Activity,className: String): Boolean {
        val activityManager =activitty.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        val info = activityManager.getRunningServices(Int.MAX_VALUE)
        if (info == null || info.size == 0) return false
        for (aInfo in info) {
            if (className == aInfo.service.className) return true
        }
        return false
    }


}